package simulation;

import java.util.ArrayList;

import messaging.MessagingServices;
import dataobjects.Position;

public class GotoMessageStim {

	public GotoMessageStim(){}

	public void run(){
		ArrayList<Position> posList = new ArrayList<Position>();
		//This is the path the seeker will take
		posList.add(new Position(0,0));
		posList.add(new Position(0,1));
		posList.add(new Position(0,2));
		posList.add(new Position(0,3));
		posList.add(new Position(0,4));
		posList.add(new Position(1,4));
		posList.add(new Position(1,3));
		posList.add(new Position(2,3));
		posList.add(new Position(2,4));
		posList.add(new Position(2,5));
		posList.add(new Position(1,5));
		posList.add(new Position(2,5));
		posList.add(new Position(3,5));
		posList.add(new Position(4,5));
		posList.add(new Position(5,5));
		posList.add(new Position(6,6));
		posList.add(new Position(7,7));
		posList.add(new Position(8,8));
		posList.add(new Position(9,9));

		ArrayList<Position> posList2 = new ArrayList<Position>();
		//This is the path the seeker will take
		posList2.add(new Position(0,0));
		posList2.add(new Position(1,0));
		posList2.add(new Position(2,0));
		posList2.add(new Position(3,0));
		posList2.add(new Position(4,0));
		posList2.add(new Position(5,0));
		posList2.add(new Position(5,1));
		posList2.add(new Position(5,2));
		posList2.add(new Position(5,3));
		posList2.add(new Position(5,2));
		posList2.add(new Position(5,1));
		posList2.add(new Position(4,1));
		posList2.add(new Position(4,2));
		posList2.add(new Position(4,3));
		posList2.add(new Position(4,4));
		posList2.add(new Position(4,5));
		posList2.add(new Position(5,5));
		posList2.add(new Position(6,6));
		posList2.add(new Position(7,7));
		posList2.add(new Position(8,8));

		ArrayList<Position> posList3 = new ArrayList<Position>();
		//This is the path the seeker will take
		posList3.add(new Position(0,0));
		posList3.add(new Position(1,0));
		posList3.add(new Position(1,1));
		posList3.add(new Position(1,2));
		posList3.add(new Position(2,2));
		posList3.add(new Position(3,2));
		posList3.add(new Position(4,2));
		posList3.add(new Position(3,2));
		posList3.add(new Position(3,3));
		posList3.add(new Position(3,4));
		posList3.add(new Position(3,5));
		posList3.add(new Position(4,5));
		posList3.add(new Position(5,5));
		posList3.add(new Position(6,6));
		posList3.add(new Position(7,7));

		MessagingServices ms = new MessagingServices(null);

		int count = 0;
		while (true){

			if (posList.size() > count){
				Position pos = posList.get(count);
				ms.sendMessage(0, pos.getX(), pos.getY());
				System.out.println("sent on channel seeker1goto: ("+pos.getX() + ", "+pos.getY()+")");
			}

			if (posList2.size() > count - 1 && count > 0){
				Position pos = posList2.get(count - 1);
				ms.sendMessage(1, pos.getX(), pos.getY());
				System.out.println("sent on channel seeker2goto: ("+pos.getX() + ", "+pos.getY()+")");
			}

			if (posList3.size() > count - 6 && count > 5){
				Position pos = posList3.get(count - 6);
				ms.sendMessage(2, pos.getX(), pos.getY());
				System.out.println("sent on channel seeker3goto: ("+pos.getX() + ", "+pos.getY()+")");
			}

			try {
				Thread.sleep(30000);//sleep 30 seconds
			} catch (InterruptedException e) {
				e.printStackTrace();
			} 
			count++;
		}
	}
	public static void main(String[] args){
		System.out.println("Beginning PCP Stim");
		GotoMessageStim g = new GotoMessageStim();
		g.run();
	}
}
